/**
 * 
 */
package sailing.dao.impl;

import java.util.List;


import cjlite.daosupport.BaseDao;
import cjlite.daosupport.SqlHelper;
import cjlite.logger.Logger;
import sailing.dao.CustomerDao;
import sailing.entity.Customer;

/**
 * @author kevin
 * 
 */
public class CustomerDaoImpl extends BaseDao implements CustomerDao {
	private static Logger logger = Logger.thisClass();

	private SqlHelper insertSql = SqlHelper.insertSql("CUSTOMER").columns("ID", "NAME", "CREATETIME");

	@Override
	public boolean save(Customer c) {
		return this.persist(c);
		// logger.entry();
		// try {
		// QueryRunner qr = this.getQueryRunner();
		// int result = qr.update(insertSql.toSqlString(), c.getId(), c.getName(), c.getCreateTime());
		// return result == 1;
		// } catch (Exception e) {
		// logger.error("error on add customer~~", e);
		// }
		// logger.exit();
		// return false;
	}

	private SqlHelper selectSql = SqlHelper.selectSql("CUSTOMER");

	@Override
	public List<Customer> getAllList() {
		return this.selectAll(Customer.class);
		// logger.entry();
		// try {
		// QueryRunner qr = this.getQueryRunner();
		// List<Customer> cList = qr.query(selectSql.toSqlString(), this.getBeanListHandler(Customer.class));
		// return cList;
		// } catch (Exception e) {
		// logger.error("error on select all customer as list ~~", e);
		// }
		// logger.exit();
		// return null;
	}

	private SqlHelper deleteSql = SqlHelper.deleteSql("CUSTOMER").where(" id = ? ");

	@Override
	public boolean delete(Customer cc) {
		return super.delete(cc);
		// logger.entry();
		// try {
		// QueryRunner qr = this.getQueryRunner();
		// int result = qr.update(deleteSql.toSqlString(), cc.getId());
		// return result == 1;
		// } catch (Exception e) {
		// logger.error("error on delete customer~~", e);
		// }
		// logger.exit();
		// return false;
	}

	private SqlHelper updateSql = SqlHelper.updateSql("CUSTOMER").columns("NAME").where(" id = ? ");

	@Override
	public boolean update(Customer cc) {
		return super.update(cc);
		// logger.entry();
		// try {
		// QueryRunner qr = this.getQueryRunner();
		// int result = qr.update(updateSql.toSqlString(), cc.getName(), cc.getId());
		// return result == 1;
		// } catch (Exception e) {
		// logger.error("error on update customer~~", e);
		// }
		// logger.exit();
		// return false;
	}

}
